import {take,put,fork} from 'redux-saga/effects';
//添加购物车
function *sagWhileAddCart() {
    while (true){
        let action=yield take('ADDCART');
        yield put({type:'addcart',action})
    }
}
//删除购物车
function *sagWhileDelectCart() {
    while (true){
        let action=yield take('DELECTCART');
        yield put({type:'delectCart',action})
    }
}
//选择购物车
function *sagWhileCheckedItem() {
    while (true){
        let action=yield take('CHECKEDITEM');
        yield put({type:'checkedItem',action})
    }
}
//点击全选
function *sagwhileClickAllChecked() {
    while (true){
        let action=yield take('CLICKALLCHECKED');
        yield put({type:'clickAllChecked',action})
    }
}
//增加数量
function *incAmount() {
    while (true){
        let action=yield take('INCAMOUNT');
        yield  put({type:'incAmount',action})
    }
}
//减少数量
function *decAmount() {
    while (true){
        let action=yield take('DECAMOUNT');
        yield put({type:'decAmount',action})
    }
}
//改变数量
function *changeAmount() {
    while (true){
        let action=yield take('CHANGEAMOUNT');
        yield put({type:'changeAmount',action})
    }
}
//改变数量
function *sagClearCart() {
    while (true){
        let action=yield take('CLEARCART');
        yield put({type:'clearCart',action})
    }
}
export default [
    fork(sagWhileAddCart),
    fork(sagWhileDelectCart),
    fork(sagWhileCheckedItem),
    fork(sagwhileClickAllChecked),
    fork(incAmount),
    fork(decAmount),
    fork(changeAmount),
    fork(sagClearCart),
]